
<?php
function Goculr($no,$type){
    //请求网址
    $host = "https://kuaidi101.market.alicloudapi.com";
    $path = "/getExpress"; //请求前缀
    $method = "GET"; //请求方式
    $appcode = "d5e253e9804a478ca9304ebcd582f1c2"; //阿里云 appcode
    $headers = array();
    array_push($headers, "Authorization:APPCODE " . $appcode);
    //$no 订单物流号 $type 快递公司 中通（zhongtong）
    $querys = "NO=$no&TYPE=$type";
    $url = $host . $path . "?" . $querys; //拼接地址
    //curl 请求
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($curl, CURLOPT_FAILONERROR, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HEADER, false);
    if (1 == strpos("$".$host, "https://")){
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    }
    //这里改成false 可以转成json格式
    curl_setopt($curl, CURLOPT_POSTFIELDS,false);
    return curl_exec($curl);
}
